Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@types/readable-stream
Advanced tools
The @types/readable-stream package provides TypeScript type definitions for the readable-stream package, which is a userland implementation of the Streams API from Node.js. This allows developers to use and interact with streams in a type-safe manner, ensuring that the code adheres to the expected interfaces and behaviors of streams.
Creating a readable stream
This feature allows you to create a readable stream that you can push data into. The stream can then be consumed by other parts of your application.
import { Readable } from 'readable-stream';
const readable = new Readable({
read(size) {
this.push('some data');
this.push(null); // No more data
}
});
readable.on('data', (chunk) => console.log(chunk.toString()));
Piping a readable stream to a writable stream
This demonstrates how to pipe data from a readable stream directly into a writable stream, effectively transferring data from one source to a destination.
import { Readable, Writable } from 'readable-stream';
const readable = new Readable({
read(size) {
this.push('data to write');
this.push(null); // No more data
}
});
const writable = new Writable({
write(chunk, encoding, callback) {
console.log(chunk.toString());
callback();
}
});
readable.pipe(writable);
The 'stream' package is actually the native Node.js Streams module. It provides the foundational building blocks for working with streams in Node.js. Compared to @types/readable-stream, it does not require type definitions because it's part of Node.js itself, but using it in TypeScript projects without type definitions might not provide the same level of type safety.
Through2 is a tiny wrapper around Node.js streams.Transform (Streams2/3) to avoid explicit subclassing noise. It's similar to @types/readable-stream in that it provides a simpler interface for working with streams, but it focuses more on transform streams and does not come with TypeScript types out of the box.
Highland.js manages synchronous and asynchronous code easily, using nothing more than standard JavaScript and Node-like Streams. While it offers functionality similar to @types/readable-stream by working with streams, it also introduces utilities for handling asynchronous operations and managing backpressure, making it more of a utility library on top of streams rather than just type definitions.
npm install --save @types/readable-stream
This package contains type definitions for readable-stream (https://github.com/nodejs/readable-stream).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/readable-stream.
_Readable
These definitions were written by TeamworkGuy2, and markdreyer.
FAQs
TypeScript definitions for readable-stream
We found that @types/readable-stream demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.